<template>
  <article class="page">
    <headerbar>通知反馈</headerbar>
    <section class="frame-content-sub no-bg">
      <section class="inner-content pdv-9 pdh-4">

        <div class="text-block" @click="showType()">
          <div class="name color-default input-name"><i class="required color-red">*</i>反馈类型：</div>
          <div class="value"><input readonly v-model="typeLabel" type="text" placeholder="请选择反馈类型"></div>
        </div>

        <div v-if="showContent" class="input-row-wrap">
          <div class="name"><i class="required color-red">*</i>请假原因：</div>
          <textarea placeholder="请填写请假原因" v-model="content" name="" cols="20" rows="3"></textarea>
        </div>

        <div class="pdv-3"></div>

        <div class="default-block-btn" @click="submit()">提交</div>

        <div class="pdv-3"></div>

      </section>
    </section>
  </article>
</template>

<script>
  import {Textarea} from 'cube-ui'
  import tools from '@/utils/tools'
  import api from '@/common/config/api'
  import loginService from '@/service/loginService'
  import moment from 'moment'
  import fileIcon from '../../../../static/images/up_document.png'
  export default {
    components: {Textarea},
    name: 'problemSetting',
    data () {
      return {
        typeLabel: '',
        typeValue: '',
        feedTypes: [],
        showContent: false,
        msgId: '',
        content: '',
        msgType: '',
        excludeType: '0'
      }
    },
    created () {
      this.msgId = this.$route.params.msgId
      this.msgType = this.$route.params.msgType
      console.log('-----------msgType=', this.msgType)
      if (this.msgType !== 'zzsh') {
        this.excludeType = '2'
      }
      this.findDictList()
    },
    methods: {
      submit () {
        if (this.showContent && this.content === '') {
          return tools.tip('请填写请假原因！')
        }

        let data = {
          // loginId: this.userInfo.id,
          loginId: '112029',
          msgId: this.msgId,
          feedInfo: this.content,
          feedType: this.typeValue
        }
        console.log("----------data=", data)
        loginService.optSaveNodeMsg(data).then((res) => {
          if (res.code !== 0) {
            return tools.tip(res.message)
          }
          tools.tip('保存成功！')
          tools.back()
        })
      },
      // 选择反馈类型
      showType () {
        this.$createActionSheet({
          title: '反馈类型',
          active: 10,
          data: this.feedTypes,
          onSelect: (item, index) => {
            this.typeLabel = item.content
            this.typeValue = item.scope
            if (this.typeValue === '2') {
              this.showContent = true
            } else {
              this.showContent = false
            }
            this.$forceUpdate()
          },
          onCancel: () => {
          }
        }).show()
      },
      findDictList () {
        this.feedTypes = []
        let data = {
          loginId: '3750',
          dictType: 'node_msg_feed_type',
          excludeType: this.excludeType
        }
        this.fetchService.findDictList(data).then(res => {
          if (res.code !== 0) {
            return tools.tip(res.message)
          }
          res.data.map((v) => {
            let types = {
              scope: v.value,
              content: v.label
            }
            this.feedTypes.push(types)
          })
          console.log('-------------feedTypes=', this.feedTypes)
        })
      }
    }
  }
</script>

<style scoped>

</style>
